﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using SMS.APP;
using SMS.APP.ViewModel;
using SMSAPP.Resources;

using SMS.MODEL;
using WPF.Themes;


namespace SMSAPP
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class HomePage : Window
    {
        private SMS.APP.ViewModel.mainMenu mainMenu = new mainMenu();
        public HomePage()
        {
            InitializeComponent();
           
            menu.ItemsSource = mainMenu.MainMenus;
            menu.Resources = this.Resources;
             
        }


        private void MenuCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            Common.IsNewForm = Convert.ToInt16(e.Parameter) > 0 ? false : true;
            MenuItem menuItem = e.OriginalSource as MenuItem;
            if (menuItem != null)
            {

                string TypeofMenu = menuItem.Tag.ToString() as string;
                if (TypeofMenu != string.Empty)
                {


                    if (TypeofMenu.ToUpper().IndexOf("THEME") >= 0)
                    {
                        Applytheme(menuItem.Header.ToString());
                    }
                    else
                    {

                        MainBorder.Child = mainMenu.getControltoView(menuItem.Tag.ToString(),this.GetType());

                    }
                }
            }
        }

        
        private void Applytheme(string themeType)
        { 
            this.ApplyTheme( Regex.Replace(themeType, " ", ""));
        
        }
    }
}